/*
 *--------------------------------------------------------------------------
 *   File Name:	syscall.S
 * 
 * Description:	none
 * 
 * 
 *      Author:	Zhao Yanbai [zhaoyanbai@126.com]
 * 
 *     Version:	1.0
 * Create Date: Tue Feb 10 13:20:33 2009
 * Last Update: Tue Feb 10 13:20:33 2009
 * 
 *--------------------------------------------------------------------------
 */

#define	ASM
#include<system.h>

#define	TASK_SIZE 4096*2
.extern sysc_handler_table
.code32
.text
.global	syscall_entry

/*
 *	0x28 -- %gs
 *	0x24 -- %fs
 *	0x20 -- %es
 *	0x1C -- %ds
 *	0x18 -- %eax
 *	0x14 -- %ebp
 *	0x10 -- %esi
 *	0x0C -- %edi
 *	0x08 -- %ecx
 *	0x04 -- %edx
 *	0x00 -- %ebx
 */

syscall_entry:
	movl	(%esp),%esp
	addl	$TASK_SIZE, %esp

	SAVE_REGS

	sti

	call	*sysc_handler_table(,%eax,4)

	movl	%eax, 0x18(%esp)	# return value

	RESTORE_REGS
	
	movl	%gs:(,%ebp), %edx
	movl	%ebp, %ecx

	sysexit

.global sysc_handler_table
.extern	sysc_write
sysc_handler_table:
.long	sysc_write
